package com.chinaisafe.user;

import com.chinaisafe.gateway.sdk.annotation.EnableAutoAuthorizationGateway;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * DemoServiceApplication
 * Description：UserService主启动类
 *
 * @author JiangZhaoYong
 * @date 2024/7/10 16:54
 */
@SpringBootApplication
@Slf4j
@EnableDiscoveryClient
@EnableAutoAuthorizationGateway
@EnableScheduling
@ComponentScan("com.chinaisafe")
public class UserServiceApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(UserServiceApplication.class, args);
        log.info("=============== DemoServiceApplication 启动成功 ===============");

        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String property = env.getProperty("server.servlet.context-path");
        String path = property == null ? "" : property;
        log.info("----------------------------------------------------------\n\t" +
                "Application is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/doc.html\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "/doc.html\n\t" +
                "userName:chinaisafe passWord:chinaisafe@2024HJ \n\t"+
                "------------------------------------------------------------");
    }
}
